package com.itheima.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

// 餐厅类
public class Restaurant implements Serializable, Comparable {
    private String name;
    private List<Menu> menuList;

    // 添加 serialVersionUID 标记类序列化编号，可以避免再次修改类时出现的java.io.InvalidClassException
    private static final long serialVersionUID = 3L;

    public Restaurant() {
    }

    public Restaurant(String name) {
        this.name = name;
        this.menuList = new ArrayList<>();
    }

    public String toString() {
        return ("餐厅名称：" + this.name);
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Menu> getMenuList() {
        return menuList;
    }

    public void setMenuList(List<Menu> menuList) {
        this.menuList = menuList;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Restaurant that = (Restaurant) o;
        return Objects.equals(name, that.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name);
    }

    @Override
    public int compareTo(Object o) {
        return ((Restaurant) o).getName().compareTo(this.getName());
    }
}